﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Accounting.DataAccess;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace Accounting.ViewModel
{
    public class BillViewModel
    {
        public BillViewModel()
        {
            Date = DateTime.Now.Date;
        }

        public BillViewModel(Bill bill)
        {
            if (null != bill)
            {
                this.Id = bill.Id;
                this.CategoryId = bill.CategoryId;
                this.SubCategoryId = bill.SubCategoryId;
                this.Date = bill.SpendDate;
                this.Remark = bill.Remark;
            }
        }

        public long Id { get; set; }

        public long CategoryId { get; set; }

        public long SubCategoryId { get; set; }

        [DataType(DataType.Date)]
        public DateTime Date { get; set; }

        public string Remark { get; set; }

        public SelectList Categories { get; set; }

        public Bill ToModel()
        {
            Bill bill = new Bill();
            bill.Id = this.Id;
            bill.CategoryId = this.CategoryId;
            bill.SubCategoryId = this.SubCategoryId;
            bill.SpendDate = this.Date;
            bill.Remark = this.Remark;
            return bill;
        }
    }
}